package com.dormitory123.millet.web;

import com.dormitory123.millet.pojo.Phone;
import com.dormitory123.millet.service.Impl.PhoneServiceImpl;
import com.dormitory123.millet.service.PhoneService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yanhuanzhan
 * @date 2022/1/4 - 17:21
 */
public class PhoneServlet extends BaseServlet{
    private PhoneService service = new PhoneServiceImpl();
    protected void list(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Phone> phones = service.list();
        //String type = req.getParameter("type");
        //req.getSession().removeAttribute("phones");
        //if (type.equals("all")) {
        //    phones = service.list();
        //} else if (type.equals("phone")) {
        //    phones = service.queryPhonesByType("手机");
        //} else if (type.equals("TV")) {
        //    phones = service.queryPhonesByType("电视机");
        //} else if (type.equals("air")) {
        //    phones = service.queryPhonesByType("空调");
        //} else if (type.equals("wash")) {
        //    phones = service.queryPhonesByType("洗衣机");
        //} else if (type.equals("proshell")) {
        //    phones = service.queryPhonesByType("保护壳");
        //} else if (type.equals("profilm")) {
        //    phones = service.queryPhonesByType("保护膜");
        //} else if (type.equals("charger")) {
        //    phones = service.queryPhonesByType("充电器");
        //}else {
        //    phones = service.queryPhonesByType("充电宝");
        //}
        req.getSession().setAttribute("phones",phones);
        req.getRequestDispatcher("/goods.jsp").forward(req,resp);
    }
}
